package com.lu.pojo.thread.syn;

import java.util.ArrayList;

/**
 * @author luzhenfang
 * @date 2020 05 24
 * @description 线程不安全集合
 */

public class UnsafeList {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i < 10000; i++) {
            new Thread(() -> {
                list.add(Thread.currentThread().getName());
            }).start();
        }
        System.out.println(list.size());
        // 与预期目标不符:不安全
    }
}
